import request from '@/utils/request'

// 查询任务列表
export function listTask(query) {
  return request({
    url: '/hanyun/task/list',
    method: 'post',
    params: query
  })
}

// 查询任务详细
export function getTask(id) {
  return request({
    url: '/hanyun/task/' + id,
    method: 'get'
  })
}

// 新增任务
export function addTask(data) {
  return request({
    url: '/hanyun/task/add',
    method: 'post',
    data: data
  })
}

// 修改任务
export function updateTask(data) {
  return request({
    url: '/hanyun/task',
    method: 'post',
    data: data
  })
}

// 删除任务
export function delTask(id) {
  return request({
    url: '/hanyun/task/' + id,
    method: 'delete'
  })
}

// 导出任务
export function exportTask(query) {
  return request({
    url: '/hanyun/task/export',
    method: 'get',
    params: query
  })
}

// 更新任务状态
export function updateTaskStatus(taskId, status) {
  return request({
    url: '/hanyun/task/status/' + taskId + '/' + status,
    method: 'post'
  })
}

// 更新任务进度
export function updateTaskProgress(taskId, progress) {
  return request({
    url: '/hanyun/task/progress/' + taskId + '/' + progress,
    method: 'post'
  })
}

// 分配任务
export function assignTask(taskId, ownerId) {
  return request({
    url: '/hanyun/task/assign/' + taskId + '/' + ownerId,
    method: 'post'
  })
}

// 添加任务依赖
export function addTaskDependency(taskId, dependsOnTaskId) {
  return request({
    url: '/hanyun/dependencies/' + taskId + '/' + dependsOnTaskId,
    method: 'post'
  })
}

// 移除任务依赖
export function removeTaskDependency(taskId, dependsOnTaskId) {
  return request({
    url: '/hanyun/dependencies/remove/' + taskId + '/' + dependsOnTaskId,
    method: 'post'
  })
}



// 查询任务依赖关系列表
export function listDependency(query) {
  return request({
    url: '/hanyun/dependencies/list',
    method: 'get',
    params: query
  })
}

// 查询任务依赖关系详细
export function getDependency(id) {
  return request({
    url: '/hanyun/dependencies/' + id,
    method: 'get'
  })
}

// 新增任务依赖关系
export function addDependency(data) {
  return request({
    url: '/hanyun/dependencies',
    method: 'post',
    data: data
  })
}

// 修改任务依赖关系
export function updateDependency(data) {
  return request({
    url: '/hanyun/dependencies',
    method: 'put',
    data: data
  })
}

// 删除任务依赖关系
export function delDependency(id) {
  return request({
    url: '/hanyun/dependencies/' + id,
    method: 'delete'
  })
}

// 导出任务依赖关系
export function exportDependency(query) {
  return request({
    url: '/hanyun/dependencies/export',
    method: 'get',
    params: query
  })
}



// 查询任务分配历史列表
export function listHistory(query) {
  return request({
    url: '/hanyun/history/list',
    method: 'get',
    params: query
  })
}

// 查询任务分配历史详细
export function getHistory(id) {
  return request({
    url: '/hanyun/history/' + id,
    method: 'get'
  })
}

// 导出任务分配历史
export function exportHistory(query) {
  return request({
    url: '/hanyun/history/export',
    method: 'get',
    params: query
  })
}
